package com.iflytek.sbd.utils;

import java.io.Serializable;

/**
 * @program: myes
 * @description:
 * @author: 陈英俊
 * @create: 2021-09-09 14:26
 */
public class RespData<T> implements Serializable {
    private static final long serialVersionUID = 1L;
    private String errCode;
    private String errMsg;
    private transient T data;
    private boolean flag;

    public RespData() {
    }

    public RespData(boolean flag, String errCode, String errMsg, T data) {
        this.flag = flag;
        this.errCode = errCode;
        this.errMsg = errMsg;
        this.data = data;
    }

    public void setResult(boolean flag, String errCode, String errMsg, T data) {
        this.flag = flag;
        this.errCode = errCode;
        this.errMsg = errMsg;
        this.data = data;
    }






    public static  RespData fail(String code) {
        return new  RespData(false, code, "返回失败", "");
    }

    public static  RespData fail(String code, String errMsg) {
        return fail(code, errMsg, "");
    }

    public static  RespData fail(String code, String errMsg, Object object) {
        return new  RespData(false, code, errMsg, object);
    }

    public static  RespData fail() {
        return new  RespData(false, "500", "返回失败", "");
    }

    public static  RespData success(String code, String errMsg, Object object) {
        return new  RespData(true, code, errMsg, object);
    }

    public static  RespData success(String code, String errMsg) {
        return new  RespData(true, code, errMsg, "");
    }

    public static  RespData success(Object object) {
        return success("-1", "操作成功", object);
    }

    public boolean isFlag() {
        return this.flag;
    }

    public void setFlag(boolean flag) {
        this.flag = flag;
    }

    public String getErrCode() {
        return this.errCode;
    }

    public void setErrCode(String errCode) {
        this.errCode = errCode;
    }

    public String getErrMsg() {
        return this.errMsg;
    }

    public void setErrMsg(String errMsg) {
        this.errMsg = errMsg;
    }

    public T getData() {
        return this.data;
    }

    public void setData(T data) {
        this.data = data;
    }
}
